import { Metadata } from "next";
import { StepList } from "~/components/steps/StepList";
import type { TaskPageParams } from "~/types/route";
import { notFound } from "next/navigation";
import { createServerClient } from "~/trpc/server-client";

interface Props {
  params: TaskPageParams;
}

export const metadata: Metadata = {
  title: "步骤管理 - 在线教育平台",
  description: "管理任务步骤",
};

export default async function StepsPage({ params }: Props) {
  if (!params.courseId || !params.taskId) {
    notFound();
  }

  const trpc = await createServerClient();
  
  try {
    const task = await trpc.tasks.getWithCourse.fetch({ 
      courseId: params.courseId,
      taskId: params.taskId,
    });

    return (
      <div className="p-6">
        <StepList 
          courseId={task.courseId} 
          taskId={task.id} 
        />
      </div>
    );
  } catch (error) {
    notFound();
  }
} 